package zstack

import (
	"bc/util"
	"encoding/json"
	"fmt"
)

type DNS struct {

}

func (d *DNS) AddDNS(dns string,l3NetworkUuid string) bool {
	oauth,err := Oauth()
	if err != nil{
		return false
	}
	url := util.Config.Zstack.ApiUrl + "v1/l3-networks/" + l3NetworkUuid + "/dns"

	body := make(map[string]interface{}, 2)
	params := make(map[string]string,1)
	params["dns"] = dns
	body["params"] = params
	body["systemTags"] = []string{}
	body["userTags"] = []string{}
	b,err := json.Marshal(body)
	h := make(map[string]string)
	h["Content-Type"] = "application/json;charset=UTF-8"
	h["Authorization"] = "OAuth " + oauth

	result,err := util.Curl.Header(h).Body(string(b)).Url(url).POST()
	fmt.Println(result)
	if err != nil {
		return false
	}
	return true
}